﻿@{
    ViewData["Title"] = "添加管理员";
    Layout = "_layout";
    var loginname = ViewBag.loginname as List<BuyWithoutLoseMoney.Core.Models.LoginUser>;
    var role = ViewBag.role as List<BuyWithoutLoseMoney.Core.Models.Role>;
}
@model List<BuyWithoutLoseMoney.Core.Models.LoginUser>;
<div>
    <div class="layui-card">
        <div class="layui-card-header">添加管理员</div>
        <div class="layui-card-body">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">管理员登录名</label>
                    <div class="layui-input-block">
                        <input type="text" name="LoginName" required lay-verify="required" placeholder="请输入管理员登录名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">管理员密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="LoginPwd" required lay-verify="required" placeholder="请输入管理员密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">联系电话</label>
                    <div class="layui-input-block">
                        <input type="text" name="Phone" required lay-verify="required" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">邮箱</label>
                    <div class="layui-input-block">
                        <input type="text" name="EMail" required lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="addForm">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
@section Scripts{
    <script>
        layui.use(["form", 'layer', 'laydate'], function () {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            var laydate = layui.laydate;

            laydate.render({
                elem: '#ID-laydate-type-datetime1',
                type: 'datetime'
            });
            //提交
            form.on('submit(addForm)', function (data) {
                $.post("/admin/management/create", data.field, function (res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function () {
                            parent.window.location.href = "/admin/management/index";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });
        })
    </script>
}